home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / yelp / xslt / toc2html.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2007-04-10  |  8.9 KB  |  253 lines

  1. <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:yelp="http://www.gnome.org/yelp/ns"
  4.                 xmlns="http://www.w3.org/1999/xhtml"
  5.                 extension-element-prefixes="yelp"
  6.                 version="1.0">
  7.  
  8. <xsl:param name="help_icon"/>
  9. <xsl:param name="help_icon_size"/>
  10.  
  11. <xsl:param name="yelp.color.fg"/>
  12. <xsl:param name="yelp.color.bg"/>
  13. <xsl:param name="yelp.color.anchor"/>
  14. <xsl:param name="yelp.color.rule"/>
  15. <xsl:param name="yelp.color.gray.fg"/>
  16. <xsl:param name="yelp.color.gray.bg"/>
  17. <xsl:param name="yelp.color.gray.bg.dark1"/>
  18. <xsl:param name="yelp.color.gray.bg.dark2"/>
  19. <xsl:param name="yelp.color.gray.bg.dark3"/>
  20. <xsl:param name="yelp.color.selected.fg"/>
  21. <xsl:param name="yelp.color.selected.bg"/>
  22. <xsl:param name="yelp.color.selected.bg.dark1"/>
  23. <xsl:param name="yelp.color.selected.bg.dark2"/>
  24. <xsl:param name="yelp.color.selected.bg.dark3"/>
  25. <xsl:param name="yelp.color.admon.fg"/>
  26. <xsl:param name="yelp.color.admon.bg"/>
  27. <xsl:param name="yelp.color.admon.bg.dark1"/>
  28. <xsl:param name="yelp.color.admon.bg.dark2"/>
  29. <xsl:param name="yelp.color.admon.bg.dark3"/>
  30.  
  31. <xsl:param name="yelp.toc.id" select="'Man-man6'"/>
  32.  
  33. <xsl:template match="toc">
  34.   <yelp:document href="{@id}">
  35.     <html>
  36.       <head>
  37.         <title>
  38.           <xsl:value-of select="title[1]"/>
  39.         </title>
  40.         <style type="text/css"><xsl:text>
  41.         body {
  42.           margin: 0px;
  43.           padding: 0px;
  44.         }
  45.         h1 {
  46.           font-size: 1.6em;
  47.           margin-bottom: 0.4em;
  48.           margin-top: 12px;
  49.           margin-left: 12px;
  50.           margin-right: 12px;
  51.           padding-left: 204px;
  52.           padding-top: 0.2em;
  53.           padding-bottom: 0.2em;
  54.           -moz-border-radius: 6px;
  55.           border: solid 1px </xsl:text>
  56.           <xsl:value-of select="$yelp.color.selected.bg.dark1"/><xsl:text>;
  57.           background-color: </xsl:text>
  58.           <xsl:value-of select="$yelp.color.selected.bg"/><xsl:text>;
  59.           color: </xsl:text>
  60.           <xsl:value-of select="$yelp.color.selected.fg"/><xsl:text>;
  61.         }
  62.         h1 img {
  63.           position: absolute;
  64.           top: 6px;
  65.           right: 18px;
  66.         }
  67.     h2 h3 {
  68.           color: </xsl:text><xsl:value-of select="$yelp.color.fg"/><xsl:text>;
  69.     }
  70.         div[class~="body"] { }
  71.         div[class~="leftbar"] {
  72.           position: absolute;
  73.           top: 4em;
  74.           left: 12px;
  75.           width: 192px;
  76.           min-height: 192px;
  77.           text-align: left;
  78.           /* padding-top: </xsl:text>
  79.           <xsl:value-of select="$help_icon_size"/><xsl:text>px;
  80.           background-image: url("</xsl:text>
  81.           <xsl:value-of select="$help_icon"/><xsl:text>");
  82.           background-position: </xsl:text>
  83.           <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px;
  84.           background-repeat: no-repeat;
  85.           opacity: .3; */
  86.         }
  87.         div[class~="leftbackground"] {
  88.           position: absolute;
  89.           top: 4em;
  90.           left: 1px;
  91.           width: 210px;
  92.           min-height: 192px;
  93.           text-align: center;
  94.           padding-top: 0px;
  95.           background-image:url("</xsl:text>
  96.           <xsl:value-of select="$help_icon"/><xsl:text>");
  97.           background-position: </xsl:text>
  98.           <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px;
  99.  
  100.           background-repeat: no-repeat;
  101.           opacity: .1;          
  102.         }
  103.         div[class~="rightbar"] {
  104.           margin-left: 216px;
  105.           padding-bottom: 1em;
  106.           padding-top: 1em;
  107.           padding-left: 1em;
  108.           padding-right: 1em;
  109.           margin-right: 12px;
  110.           background-color: </xsl:text><xsl:value-of select="$yelp.color.bg"/><xsl:text>;
  111.           color: </xsl:text><xsl:value-of select="$yelp.color.fg"/><xsl:text>;
  112.           -moz-border-radius: 8px;
  113.         }
  114.         ul { margin-left: 0em; padding-left: 0em; }
  115.         li[class~="toclist"] {
  116.           margin-top: 0.3em;
  117.           margin-left: 0em;
  118.           padding-left: 0em;
  119.           font-size: 1.2em;
  120.           list-style-type: none;
  121.         }
  122.     li li[class~="toclist"] {
  123.       padding-left: 0.8em;
  124.       font-size: 0.8em;
  125.         }
  126.     li li li[class~="toclist"] {
  127.       padding-left: 0.8em;
  128.       font-size: 0.6em;
  129.         }
  130.         li[class~="toc"] {
  131.           margin-left: 0em;
  132.           font-size: 1.2em;
  133.           padding-top: 0.5em;
  134.           list-style-type: none;
  135.         }
  136.         dl { margin-left: 0em; padding-left: 0em; }
  137.         dt { font-size: 1.2em; margin-top: 1em; }
  138.         dd { margin-left: 1em; margin-top: 0.5em; }
  139.         a { text-decoration: none; color: </xsl:text><xsl:value-of select="$yelp.color.anchor"/><xsl:text>; }
  140.         a:hover { text-decoration: underline; }
  141.         </xsl:text></style>
  142.       </head>
  143.       <body>
  144.         <xsl:apply-templates mode="body.mode" select="."/>
  145.       </body>
  146.     </html>
  147.   </yelp:document>
  148. </xsl:template>
  149.  
  150. <xsl:template name="print.documents">
  151.   <div class="docs">
  152.     <dl>
  153.       <xsl:for-each select="doc">
  154.         <xsl:sort select="normalize-space(title)"/>
  155.         <dt class="doc">
  156.           <a href="{@href}" title="{@href}">
  157.             <xsl:if test="tooltip">
  158.               <xsl:attribute name="title">
  159.                 <xsl:value-of select="tooltip"/>
  160.               </xsl:attribute>
  161.             </xsl:if>
  162.             <xsl:value-of select="title"/>
  163.           </a>
  164.         </dt>
  165.         <dd>
  166.           <xsl:value-of select="description"/>
  167.  
  168.         </dd>
  169.       </xsl:for-each>
  170.     </dl>
  171.   </div>
  172. </xsl:template>
  173.  
  174. <xsl:template name="print.subsections">
  175.   <div class="tocs">
  176.     <ul>
  177.       <xsl:for-each select="toc[../@id = 'index' or .//doc]">
  178.         <xsl:sort select="number(../@id = 'index') * position()"/>
  179.         <xsl:sort select="normalize-space(title)"/>
  180.         <li class="toc">
  181.           <a href="x-yelp-toc:{@id}">
  182.             <xsl:apply-templates select="title[1]/node()"/>
  183.           </a>
  184.         </li>
  185.       </xsl:for-each>
  186.     </ul>
  187.   </div>
  188. </xsl:template>
  189.  
  190. <xsl:template mode="body.mode" match="toc">
  191. <div class="leftbackground">
  192.   </div>
  193.   <div class="body">
  194.     <h1>
  195.       <xsl:if test="icon">
  196.         <img src="{icon/@file}"/>
  197.       </xsl:if>
  198.       <xsl:apply-templates select="title"/>
  199.     </h1>
  200.     <div class="rightbar">
  201.       <h3><xsl:apply-templates select="description/node()"/></h3>
  202.       <xsl:choose>
  203.         <!-- if there are documents and subsections, only print documents -->
  204.         <xsl:when test="doc[1] and toc[.//doc[1]]">
  205.           <xsl:call-template name="print.documents"/>
  206.         </xsl:when>
  207.         <!-- if there are documents, print them -->
  208.         <xsl:when test="doc[1]">
  209.           <xsl:call-template name="print.documents"/>
  210.         </xsl:when>
  211.         <xsl:otherwise>
  212.           <xsl:choose>
  213.             <xsl:when test="@id='index'">
  214.               <!-- Main page!!! -->
  215.               <div class="leftbar">
  216.                 <h2><xsl:value-of select="topic_title"/></h2>
  217.                 <xsl:for-each select="topics//topic">
  218.                   <xsl:sort order="descending" data-type="number" select="@priority"/>
  219.                   <h3><a href="{@uri}"><xsl:value-of select="."/></a></h3>
  220.                 </xsl:for-each>
  221.               </div>
  222.               
  223.               <p><xsl:value-of select="desc1"/></p>
  224.               <h3><xsl:value-of select="common"/></h3>
  225.               <ul>
  226.                 <li><a href="ghelp:internet#connect-to-internet"><xsl:value-of select="q1"/></a></li>
  227.                 <li><a href="ghelp:desktop-effects"><xsl:value-of select="q2"/></a></li>
  228.                 <li><a href="ghelp:musicvideophotos#music"><xsl:value-of select="q3"/></a></li>
  229.                 <li><a href="ghelp:musicvideophotos#photos"><xsl:value-of select="q4"/></a></li>
  230.                 <li><a href="ghelp:keeping-safe#updates"><xsl:value-of select="q5"/></a></li>
  231.               </ul>          
  232.               <h3><xsl:value-of select="notfound"/></h3>
  233.               <p><xsl:value-of select="freesupport_pre"/><xsl:text> </xsl:text> <a href="{freesupport_loc}"><xsl:value-of select="freesupport_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="freesupport_after"/></p>
  234.               <p><xsl:value-of select="commercialsupport_pre"/><xsl:text> </xsl:text> <a href="{commercialsupport_loc}"><xsl:value-of select="commercialsupport_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="commercialsupport_after"/></p>
  235.               <h3><xsl:value-of select="how_contribute"/></h3>
  236.               <p><xsl:value-of select="community_pre"/><xsl:text> </xsl:text> <a href="{community_loc}"><xsl:value-of select="community_link"/></a><xsl:text> </xsl:text> <xsl:value-of select="community_after"/></p>
  237.             </xsl:when>
  238.             <xsl:otherwise>
  239.               <xsl:call-template name="print.subsections"/>
  240.             </xsl:otherwise>
  241.           </xsl:choose>
  242.         </xsl:otherwise>
  243.       </xsl:choose>
  244.     </div>
  245.   </div>
  246. </xsl:template>
  247.  
  248. <xsl:template match="/">
  249.   <xsl:apply-templates select="//toc[@id = $yelp.toc.id]" />
  250. </xsl:template>
  251.  
  252. </xsl:stylesheet>
  253.